package acwing.dfs;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;

/**
 * t
 *
 * @author yang
 * @date 2021/12/21
 */
public class t {

    public static void main(String[] args) {
        t.m(new int[]{1,2,3});
    }


    static boolean[] f;
    static int[] path;
    public static void m(int[] a) {
        path = new int[a.length];
        f = new boolean[a.length + 1];
        dfs(0,a);

    }

    private static void dfs(int u,int[] a) {

        if (u == a.length) {
            for (int i = 0; i < path.length; i++) {
                System.out.print(path[i]);
            }
            System.out.println();
            return;
        }
        for (int i = 0; i < a.length; i++) {
            if (!f[i]) {
                path[u] = a[i];
                f[i] = true;
                dfs(u + 1, a);
                f[i] = false;
            }
        }
    }
}
